<template>
  <d2-container>

      <template slot="header">上课出勤率区间详细</template>
        <el-main>
          <el-table v-bind="table" border style="width: 100%;" :height='600'>
             <el-table-column
                    v-for="(item, index) in table.columns"
                    :key="index"
                    :prop="item.prop"
                    :label="item.label">
            </el-table-column>
<!--             <el-table-column  prop="commission" label="提成奖金（元）"></el-table-column>
            <el-table-column prop="createdAtText" label="开课时间"></el-table-column> -->
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button
                  @click="handleClassOrderDetailClick(scope.row)"
                  type="text"
                  size="normal"
                  style
                >查看</el-button>
                
                <div></div>
              </template>
            </el-table-column>
          </el-table>
        </el-main>


  </d2-container>
</template>


<script>
    import request from "@/plugin/axios";
    import formatTime from '@/libs/util.formatTime.js'
    export default {
        data() {
            return {
              showCommission : false,
                class_id: undefined,
                class_student: undefined,
                class_info: {'course':{},'school':{}},
                class_order_list: undefined,
                studentList : [],
                selectStudent : undefined,
                searchStudentName : undefined,
                disabled : true,
                activeName : 'detail',
                newCommission : 0,
                commissionID : undefined,
                table: {
                    columns: undefined,
                    data: undefined,
                    size: 'mini',
                    stripe: true,
                    border: true
                },

            };
        },
        methods: {
            


          handleClassOrderDetailClick(e){
            this.$router.push({path:'/class-order-detail?id=' + e._id})
          },

            getClassOrderList() {
              let data = {}
              data.start_time = this.startTime
              data.period = this.period
              if (this.staff){
                data.staff = this.staff
              }
              if (this.school){
                data.school = this.school
              }
                request({
                    url: "/classOrder/getClassAttendanceList",
                    method: "post",
                    data: data
                }).then(res => {
                    if (res.code == 200) {
                        this.table.columns = res.data.columns
                        for (var i =0 ; i < res.data.data.length ; i++){
                          res.data.data[i]['total'] = parseFloat(res.data.data[i]['total']).toFixed(1)
                          res.data.data[i]['commission'] = parseFloat(res.data.data[i]['commission']).toFixed(1)
                        }
                        this.table.data = res.data.data
                        
                    }

                });
            },





        
          },



        created() {
            // start time . end time , 
            // if (this.$route.query.class_id != undefined) {
            //     this.class_id = this.$route.query.class_id;
            //     this.getClassStudentList();
            //     this.getClassDetail();
            //     this.getClassOrderList();
            // }
            this.startTime = this.$route.query.startTime
            this.period = this.$route.query.period
            this.staff = this.$route.query.staff
            this.school = this.$route.query.school
            this.getClassOrderList()
            
        }
};
</script>
